	<script type="text/javascript">
	var winning = [
	<?php 
		foreach (Globals::award() as $key) {
			echo '"'. $key .'",';
		}
	?>
	];
	$(function(){
		var check = function(){
			// alert($('#ticket').val());
			if ($('#ticket').val() == "") {
				$(".msg").html("没有填写奖券号码。");
				return;
			};
			$(".msg").html("查询中...");
			$(".tid").val('');
			$.get("<?php echo Yii::app()->request->getUrl();?>",{'ticket':$('#ticket').val()},
				function(data){
					// alert(data.ddd);
					// alert(data instanceof Object);
					if (data instanceof Object) {
						if (data.code === 0) {
							var obj = data.data;
							if (obj != undefined ) {
								var str = "摇奖活动："+ obj.event + "<br>";
								str += "中奖人：" + obj.username + "<br>";
								str += "手机号：" + obj.mobile + "<br>";
								if (obj.winning == 0) {
									str += "奖项：" + winning[obj.winning] + "<br>";
								}else{
									str += "<span style='color:green;'>奖项：" + winning[obj.winning] + "</span><br>";
									if (obj.stat == 0) {
										str += "兑奖状态：未兑奖<br>";
										$(".tid").val(obj.id);
									}else{
										str += "<span style='color:red;'>兑奖状态：已兑奖</span><br>";
									}
								}
								str += "摇奖时间：" + obj.time + "<br>";
								str += "中奖时间：" + obj.wintime + "<br>";
								$(".msg").html(str);
								$('#ticket').val('');
							}else{
								$(".msg").html("没有找到奖券信息。");
							}
						}else{
							$(".msg").html(data.message);
						}
					}else{
						$(".msg").html($('#ticket').val() + "奖券输入不正确。");
					}
			},'json');

		}

		var pay = function(){
			if ($('.tid').val() == "") {
				$(".msg").html("请先验证一个获奖的奖券。");
				return;
			};

			$.get("<?php echo Yii::app()->request->getUrl();?>",{'tid':$('.tid').val()},
				function(data){
					// if (data.code === 0) {
						$(".msg").html(data.message + "<br>" + $(".msg").html()  );
					// }else{
						// $(".msg").html($(".msg").html() + "<br>" + data.message);
					// }
				},"json");
		}

		$(".start").click(pay);
		$(".ticket").bind('keydown', function (e) {
            var key = e.which;
            if (key == 13) {
                e.preventDefault();
                // var nxtIdx = $inp.index(this) + 1;
                // $(":input:text:eq(" + nxtIdx + ")").focus();
                check();
            }
        });
		
		$(".ticket").focus();
		
	})
		
	</script>
	<style>
	body
	{
		background-size: 100% 670px;
		background-image: url(../server/css/bg2.png);
	}
	#header img
	{
		width: 70%;
	}
	#footer{display: none;}
	.wrap{ 
		width:584px; 
		margin: 0 auto;
		padding-top:10px; 
		font-family:"微软雅黑";}
	.show{ 
		width:584px; 
		height:90px; 
		background-image: url(../server/css/input-bg.png);
		text-align:center; 
		color:#fff; 
		font-size:28px; 
		line-height: 90px;
		 
	}
	.btn a{ 
		display:block; 
		width:524px; 
		height:108px; 
		margin:30px auto; 
		text-align:center; 
		text-decoration:none; color:#fff; 
		-moz-border-radius:150px; 
		-webkit-border-radius:150px; 
		border-radius:150px;
		font-size:40px; 
		line-height: 100px;
	}
	.btn a.start{ 
		background-image: url(../server/css/button.png);
	}
	.btn a.start:hover{ }
	.btn a.stop{ background:#00a2ff;}
	.btn a.stop:hover{ background:#008bdb;}

	.ticket{
		background-color: rgba(0,0,0,0);
		border:0;
		padding:0;
		margin: 0;
		text-align:center; 
		color:#fff; 
		font-size:45px; 
		line-height: 90px;
		width:500px; 
	}
	.msg {
		color:#fff; 
		font-size:23px; 
		line-height: 35px;
		text-align: left;
		background-color: rgba(0,0,0,0.3);
		-moz-border-radius:5px; 
		-webkit-border-radius:5px; 
		border-radius:5px;
		padding: 10px;
		margin-top: 20px;
	}
	</style>

<div class="wrap">
	<input type="hidden" class="tid">
	<div class="show" id="show">
		<input id="ticket" class="ticket" >
	</div>
	
	<div class="msg">
		请输入奖券，并回车验证奖券！<br>
		点击兑奖发放奖品。<br>
		
	</div>
	<div class="btn">
		<a href="javascript:void(0);" class="start" id="btn">点击发奖</a>
	</div>
</div>


